<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<link rel="stylesheet" type="text/css" href="../../css/style.css" />
		<link rel="stylesheet" type="text/css" href="../../css/demo.css" />
		<script src="../../js/demo.js" type="text/javascript" charset="utf-8"></script>
		<title>商品管理</title>
	</head>
	<body>
		<!--header-->
		<div class="header">
			<div class="header-content">
				<ul class="nav left">
					<li><img src="../../img/regist-arrow.png" /></li>
					<li class="nav-one">
						<a href="javascript:history.go(-1);">返回</a>
					</li>
					<li class="nav-two">
						<a href="../../index.html">关闭</a>
					</li>
				</ul>
				<p class="left">商品管理</p>
				<div class="right nav_right">
					<img src="../../img/regist-list.png" />
				</div>
			</div>
		</div>
		<!--main-->
		<div class="main clear" id="selectCollectGood">
			<ul class="productcollect-nav ">
				<li class="productactive">全部商品</li>
				<li>已失效</li>
			</ul>		
		</div>
	</body>
	
	<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
	<script type="text/javascript">
		selectCollectGood();
		function selectCollectGood(){
			$.ajax({
				type:"post",
				url:"/qiaomengapp/userFocus/selectCollectGood",
				dataType:"json",
				success:function(data){
					for (var i = 0; i < data.length; i++) {
						var good=data[i];				
						$('#selectCollectGood').html($('#selectCollectGood').html()+
								"<div class='productcollect-pro'>"+
								"<div class='productcollect-line'>"+
									"<div class='productcollect-list' >"+
										"<img src='"+good.goodImgurl+"' />"+
										"<ul class='productcollect-listes left'>"+
											"<a href='../../html/product/productlist.html?"+good.id+"'><li class='productcollect-one'>"+good.goodDesc+"</li></a>"+
											"<li class='productcollect-two'>￥"+good.price+"<span class='product-delete right'><img onclick='deleteCollectGood()' shopGoodId='"+good.id+"' src='../../img/product-icon14.png' style='width: 0.31rem;height: 0.38rem;margin-top: -0.24rem;''/></span></li>"+
										"</ul>"+
									"</div>"+
								"</div>"	
						);
					}	
				}
			});
		}
		
		//没返回数据就不用写dataType,和success:function(data){}中的data也不用写
		function deleteCollectGood(){
			var $img= $(event.target);
			var shopGoodId=$img.attr("shopGoodId");
			$.ajax({
				type:"post",
				url:"/qiaomengapp/userFocus/deleteCollectGood",
				data:"shopGoodId="+shopGoodId,
				success:function(){
					alert("删除成功");
					$img.closest($('.productcollect-pro')).remove();
				}
			});
		}
	</script>
</html>